package com.wiloon.java8x.concurrentmodification;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: wiloon
 * Date: 7/8/12
 * Time: 3:50 PM
 */
public class CM {
    private List<String> listA;
    private List<String> listB;

    public CM() {
        //listA = new ArrayList<String>();
        //listB = new ArrayList<String>();
        listA = new CopyOnWriteArrayList<String>();
        listB = new CopyOnWriteArrayList<String>();
        listA.add("A");
        listA.add("B");
        listA.add("C");
        listB.addAll(listA);

    }

    public void test() {
        for (String s : listA) {
            for (String ss : listB) {
                listA.remove(s);
                listB.remove(ss);
            }
        }
    }

    public static void main(String[] args) {
        CM cm = new CM();
        cm.test();
        System.out.println("end...");
    }
}
